print "analyze the connected edges begin..."
inputFileName = "/data3/obukai/the_new_trip_of_feature_generation/gov2ClearYourMindAndDoItAgain/gov2DocumentWithTheirConnectedEdges"
inputFileHandler = open(inputFileName,"r")

queryTermPairWithTheirFreqAndIndexNumberDict = {}

inputFileName2 = "/data3/obukai/the_new_trip_of_feature_generation/gov2ClearYourMindAndDoItAgain/queryTermPairProbabilityOfTheQueryTrace_sorted_by_query_term_pair"
inputFileHandler2 = open(inputFileName2,"r")

for line in inputFileHandler2.readlines():
    lineElements = line.strip().split(" ")
    uniqueID = lineElements[0]
    term_pair = lineElements[1]
    freq = lineElements[2]
    
    key = uniqueID
    value = (term_pair,freq)
    
    if key not in queryTermPairWithTheirFreqAndIndexNumberDict: 
        queryTermPairWithTheirFreqAndIndexNumberDict[key] = value
    else:
        print "mark1 error"
        exit(1)

print "len(queryTermPairWithTheirFreqAndIndexNumberDict):",len(queryTermPairWithTheirFreqAndIndexNumberDict)
    
inputFileHandler2.close()

# Load and ignore the header line
inputFileHandler.readline()

# Load the whole things into main memory
line = inputFileHandler.readline()
print line
lineElements = line.strip().split(" ")
docID = lineElements[0]
NUM_OF_EDGES = int(lineElements[1])
for i in range(0,NUM_OF_EDGES):
    key = lineElements[i+2]
    print key,queryTermPairWithTheirFreqAndIndexNumberDict[ key ]





inputFileHandler.close()

print "analyze the connected edges end."